<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>xhrio.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">xhrio.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Wrapper class for handling XmlHttpRequests.

 One off requests can be sent through goog.net.XhrIo.send() or an
 instance can be created to send multiple requests.  Each request uses it&#39;s
 own XmlHttpRequest object and handles clearing of the event callback to
 ensure no leaks.

 XhrIo is event based, it dispatches events for when a request has finished,
 when it is errorred or has succeeded, or when the ready-state changes.
 The Ready-state event fires first first, followed by a generic completed
 event, and lastly the error or success event is fired as appropriate.

 The error event may also be called before completed and
 ready-state-change if the XmlHttpRequest.open() or .send() methods throw.

 This class does not support multiple requests, queuing, or prioritization.

 Tested = IE6, FF1.5, Safari, Opera 8.5

 TODO: Error cases aren&#39;t playing nicely in Safari.
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_net_xhrio.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">net/xhrio.js</div>
    </div>
  </div>
<hr/>


  <h2>Classes</h2>
 <div class="fn-constructor">
        <a href="class_goog_net_XhrIo.html">
          goog.net.XhrIo</a><br/>
        <div class="class-details">Basic class for handling XMLHttpRequests.</div>
 </div>
      
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>


  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.XhrIo.cleanup"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.XhrIo.</span><span class="entryName">cleanup<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_xhrio.js.source.html#line154">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.net.XhrIo.cleanupSend_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.XhrIo.</span><span class="entryName">cleanupSend_<span class="args">(<span class="arg">XhrIo</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Disposes of the specified goog.net.XhrIo created by
{@link goog.net.XhrIo.send} and removes it from
{@link goog.net.XhrIo.pendingStaticSendInstances_}.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">XhrIo</span>
        : <div class="fullType"><span class="type"><a href="class_goog_net_XhrIo.html">goog.net.XhrIo</a></span></div>
        <div class="entryOverview">An XhrIo created by {@link goog.net.XhrIo.send}.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_xhrio.js.source.html#line191">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.XhrIo.protectEntryPoints"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.XhrIo.</span><span class="entryName">protectEntryPoints<span class="args">(<span class="arg">errorHandler</span>,&nbsp;<span class="arg">opt_tracers</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Installs exception protection for all entry point introduced by
goog.net.XhrIo instances which are not protected by
{@link goog.debug.ErrorHandler#protectWindowSetTimeout},
{@link goog.debug.ErrorHandler#protectWindowSetInterval}, or
{@link goog.events.protectBrowserEventEntryPoint}.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">errorHandler</span>
        : <div class="fullType"><span class="type"><a href="class_goog_debug_ErrorHandler.html">goog.debug.ErrorHandler</a></span></div>
        <div class="entryOverview">Error handler with which to protect the entry point(s).</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_tracers</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">Whether to install tracers around the entry point.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_xhrio.js.source.html#line174">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.XhrIo.send"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.XhrIo.</span><span class="entryName">send<span class="args">(<span class="arg">url</span>,&nbsp;<span class="arg">opt_callback</span>,&nbsp;<span class="arg">opt_method</span>,&nbsp;<span class="arg">opt_content</span>,&nbsp;<span class="arg">opt_headers</span>,&nbsp;<span class="arg">opt_timeoutInterval</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Static send that creates a short lived instance of XhrIo to send the
request.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">url</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span></div>
        <div class="entryOverview">Uri to make request too.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_callback</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
        <div class="entryOverview">Callback function for when request is complete.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_method</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">Send method, default: GET.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_content</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span><span>&nbsp;|&nbsp;</span><span class="type">GearsBlob</span></div>
        <div class="entryOverview">Post data. This can be a Gears blob if the underlying HTTP request object is a Gears HTTP request.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_headers</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="class_goog_structs_Map.html">goog.structs.Map</a></span></div>
        <div class="entryOverview">Map of headers to add to the request.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_timeoutInterval</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">Number of milliseconds after which an incomplete request will be aborted; 0 means no timeout is set.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_xhrio.js.source.html#line121">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



  <h2>Global Properties</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.net.XhrIo.CONTENT_TYPE_HEADER"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.XhrIo.</span><span class="entryName">CONTENT_TYPE_HEADER</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
     </div>


     <div class="entryOverview">
       The Content-Type HTTP header name
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_net_xhrio.js.source.html#line85">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.net.XhrIo.FORM_CONTENT_TYPE"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.XhrIo.</span><span class="entryName">FORM_CONTENT_TYPE</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
     </div>


     <div class="entryOverview">
       The Content-Type HTTP header value for a url-encoded form
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_net_xhrio.js.source.html#line92">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.net.XhrIo.sendInstances_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.XhrIo.</span><span class="entryName">sendInstances_</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="class_goog_net_XhrIo.html">goog.net.XhrIo</a></span>&gt;</div>
     </div>


     <div class="entryOverview">
       All non-disposed instances of goog.net.XhrIo created
by {@link goog.net.XhrIo.send} are in this Array.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_net_xhrio.js.source.html#line103">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory net</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="closure/goog" current="net/xhrio.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
